//
//  ZYMainViewController.swift
//  ZYweibo
//
//  Created by 张耀 on 16/6/25.
//  Copyright © 2016年 zhangyao. All rights reserved.
//

import UIKit

class ZYMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //自定义tabBar
        let tabBar = ZYTabBar()
        
        //通过KVC给只读属性赋值
        setValue(tabBar, forKey: "tabBar")
        
        //设置代理
        tabBar.zyDelegate = self
    
        super.viewDidLoad()
        addChildViewController(ZYHomeTableViewController(),title: "首页",imageName: "tabbar_home")
        addChildViewController(ZYXiaoxiTableViewController(),title: "消息",imageName: "tabbar_message_center")
        addChildViewController(ZYFaxianTableViewController(),title: "发现",imageName: "tabbar_discover")
        addChildViewController(ZYWodeTableViewController(),title: "我的",imageName: "tabbar_profile")
        
       
    }
    
    func addChildViewController(homel:UIViewController,title:String,imageName:String){
    
        homel.title = title
        homel.tabBarItem.image = UIImage (named: imageName)
        homel.tabBarItem.selectedImage = UIImage (named: "\(imageName)_selected")
        let nav = UINavigationController(rootViewController: homel)
        addChildViewController(nav)
    }
    
}
extension ZYMainViewController:ZYTabBarDelegate{

    func jiahaoButtonClick() {
        
        print("弹出控制器")
    }

}